package zhengbeihong;

import java.util.Scanner;

public class MainView {
    public static final String MENU = """
                       ------------
                          部门管理
                       ------------
                       | 0 返回上级 |
                       | 1 部门列表 |
                       | 2 添加部门 |
                       | 3 修改部门 |
                       | 4 删除部门 |
                       ------------
                       请输入选项:""";
    public static Scanner input;

    static {
        input = new Scanner(System.in);
    }

    public final DeptView deptView;

    public final RoleView roleView;

    public final UserView userView;

    private static MainView singleton;



    private MainView() {
        deptView = DeptView.getInstance();
        roleView = RoleView.getInstance();
        userView = UserView.getInstance();
    }
    public static MainView getInstance() {
        if (singleton == null) {
            singleton = new MainView();
        }
        return singleton;
    }

    public  void show() {
        String menuChoice;
        do {
            System.out.println( MENU );
            menuChoice = input.nextLine();
            switch (menuChoice) {
                case "0" -> System.out.println("成功退出系统，欢迎再次使用");
                case "1" -> deptView.show();
                case "2" -> roleView.show();
                case "3" -> userView.show();
                default -> System.out.println("输入非法，请输入正确的菜单编号 ");
            }
        } while (!"0".equals(menuChoice));
        input.close();
    }

}